from rest_framework import status
from rest_framework.response import Response

'''
返回结果方法封装
'''


def get_success_response(data):
    return Response(({"code": 200, "success": True, "message": "操作成功", "data": data}), status=status.HTTP_200_OK)


def get_error_response(data):
    return Response(data, status=status.HTTP_200_OK)


# 返回结果常量
DATA_DUPLICATION = {"code": 1001, "success": False, "message": "数据重复", "data": ""}
DATA_ABSENT = {"code": 1002, "success": False, "message": "数据不存在", "data": ""}
PARAMS_MISSING = {"code": 1002, "success": False, "message": "参数缺失", "data": ""}
CRON_EXPRESSION_EXCEPTION = {"code": 1003, "success": False, "message": "cron表达式不合规", "data": ""}
SYSTEM_EXCEPTION = {"code": 500, "success": False, "message": "系统异常，请联系管理员", "data": ""}

MQTT_DISCONNECT = {"code": 501, "success": False, "message": "MQTT client not connected", "data": ""}
